home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacHack 2000
/
MacHack 2000.toast
/
pc
/
The Hacks
/
Softshoe
/
Lisa's Mac Parts
/
Application
/
ApplicationBase.cp
< prev
next >
Wrap
Text File
|
2000-06-23
|
2KB
|
107 lines
// ApplicationBase.cp
#ifndef ApplicationBase_h
#include "ApplicationBase.h"
#endif
#ifndef EventQueue_h
#include "EventQueue.h"
#endif
#ifndef BroadcastLoop_h
#include "BroadcastLoop.h"
#endif
#ifndef OSError_h
#include "OSError.h"
#endif
#ifndef AEEvent_h
#include "AEEvent.h"
#endif
#ifndef UserState_h
#include "UserState.h"
#endif
#ifndef ProcessInfo_h
#include "ProcessInfo.h"
#endif
#ifndef Commander_h
#include "Commander.h"
#endif
#ifndef Quitter_h
#include "Quitter.h"
#endif
#ifndef ApplicationFocus_h
#include "ApplicationFocus.h"
#endif
#include <Errors.h>
ApplicationBase *ApplicationBase::the = 0;
ApplicationBase::ApplicationBase( uint32 masterPointers,
uint32 extraStackSpace )
: ApplicationZoneUser( masterPointers, extraStackSpace )
{
Assert( the == 0 );
the = this;
Assert( !ProcessInfo::Application().IsDeskAccessory() );
Assert( ProcessInfo::Application().HighLevelEventAware() );
Assert( ProcessInfo::Application().CleanFor32Bits() );
}
ApplicationBase::~ApplicationBase()
{
}
void ApplicationBase::Run()
{
ApplicationFocus::The().SynchronizeWithProcessManager();
UserState::The().Announce();
for ( EventQueue& queue( EventQueue::The() );
queue.Unfinished();
queue++ )
{
try
{
HandleEvent( *queue );
}
catch ( ... )
{
Assert( 0 );
}
}
}
void ApplicationBase::OpenApplication( const AEEvent& event,
AEEvent& )
{
event.ThrowMissedParameter();
if ( !CanCreate() )
throw OSError( errAEEventFailed );
Create();
}
void ApplicationBase::OpenDocuments( const AEEvent&,
AEEvent& )
{
throw OSError( errAEEventNotHandled );
}
void ApplicationBase::PrintDocuments( const AEEvent&,
AEEvent& )
{
throw OSError( errAEEventNotHandled );
}
void ApplicationBase::QuitApplication( const AEEvent&,
AEEvent& )
{
Quitting& quitter( Quitter::The() );
if ( !quitter.CanStartQuitting() )
throw OSError( errAEEventFailed );
quitter.StartQuitting();
}